home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
Menu.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
5KB
|
142 lines
class Menu extends PopUp
{
static var sSOUND_STATE_ON = "SoundOn";
static var sSOUND_STATE_OFF = "SoundOff";
static var sMUSIC_STATE_ON = "MusicOn";
static var sMUSIC_STATE_OFF = "MusicOff";
static var sMENU_OPTIONS = "Options";
static var sMENU_QUIT = "Quit";
function Menu(_mcRef)
{
super(_mcRef);
}
function doShow()
{
if(this.sState == PopUp.sSTATE_IDLE)
{
this.setState(PopUp.sSTATE_OPENING);
Controller.getRef().getSounds().playSound("Menu_In",Controller.nSFX_VOLUME,1);
this.updateSoundButton();
this.updateMusicButton();
Controller.getRef().pauseGame();
}
}
function doHide()
{
if(this.sState == PopUp.sSTATE_OPENED)
{
this.setState(PopUp.sSTATE_CLOSING);
Controller.getRef().getSounds().playSound("Menu_Out",Controller.nSFX_VOLUME,1);
this.updateSoundButton();
this.updateMusicButton();
Controller.getRef().unPauseGame();
}
}
function clickSoundButton()
{
Controller.getRef().playClickSound();
if(Controller.getRef().isSoundsMuted())
{
Controller.getRef().unMuteSounds();
}
else
{
Controller.getRef().muteSounds();
}
this.updateSoundButton();
}
function clickMusicButton()
{
Controller.getRef().playClickSound();
if(Controller.getRef().isMusicMuted())
{
Controller.getRef().unMuteMusic();
}
else
{
Controller.getRef().muteMusic();
}
this.updateMusicButton();
}
function resume()
{
Controller.getRef().playClickSound();
this.doHide();
}
function updateSoundButton()
{
if(Controller.getRef().isSoundsMuted())
{
this.mcRef.mcState.mcPanel.mcSound.gotoAndStop(Menu.sSOUND_STATE_OFF);
}
else
{
this.mcRef.mcState.mcPanel.mcSound.gotoAndStop(Menu.sSOUND_STATE_ON);
}
this.mcRef.mcState.mcPanel.mcSound.btnSound.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.mcSound.btnSound.onRelease = Delegate.create(this,this.clickSoundButton);
}
function updateMusicButton()
{
if(Controller.getRef().isMusicMuted())
{
this.mcRef.mcState.mcPanel.mcMusic.gotoAndStop(Menu.sMUSIC_STATE_OFF);
}
else
{
this.mcRef.mcState.mcPanel.mcMusic.gotoAndStop(Menu.sMUSIC_STATE_ON);
}
this.mcRef.mcState.mcPanel.mcMusic.btnMusic.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.mcMusic.btnMusic.onRelease = Delegate.create(this,this.clickMusicButton);
}
function gotoQuitMenu()
{
Controller.getRef().playClickSound();
this.showQuitMenu();
}
function gotoOptionsMenu()
{
Controller.getRef().playClickSound();
this.showOptionsMenu();
}
function showOptionsMenu()
{
this.mcRef.mcState.gotoAndStop(Menu.sMENU_OPTIONS);
this.updateSoundButton();
this.updateMusicButton();
this.mcRef.mcState.mcPanel.btnResume.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.btnResume.onRelease = Delegate.create(this,this.resume);
this.mcRef.mcState.mcPanel.btnHowToPlay.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.btnHowToPlay.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickInstructionsButton);
this.mcRef.mcState.mcPanel.btnQuit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.btnQuit.onRelease = Delegate.create(this,this.gotoQuitMenu);
}
function showQuitMenu()
{
Controller.getRef().playClickSound();
this.mcRef.mcState.gotoAndStop(Menu.sMENU_QUIT);
this.mcRef.mcState.mcPanel.btnYes.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.btnNo.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
this.mcRef.mcState.mcPanel.btnYes.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickQuitButton);
this.mcRef.mcState.mcPanel.btnNo.onRelease = Delegate.create(this,this.gotoOptionsMenu);
}
function Opening()
{
if(this.stateFinished())
{
this.setState(PopUp.sSTATE_OPENED);
this.showOptionsMenu();
}
}
function Opened()
{
}
function Closing()
{
if(this.stateFinished())
{
this.setState(PopUp.sSTATE_IDLE);
}
}
}